import request from '../utils/request'

// 添加到购物车
export function addToCart(skuId, number) {
  return request({
    url: '/cart/add',
    method: 'post',
    params: {
      skuId,
      number
    }
  })
}

// 获取购物车列表
export function getCartList() {
  return request({
    url: '/cart/list',
    method: 'get'
  })
}

// 从购物车删除
export function deleteFromCart(id) {
  return request({
    url: '/cart/delete',
    method: 'delete',
    params: {
      id
    }
  })
}

// 获取购物车子列表
export function getSubCartList(uid, cartIds) {
  return request({
    url: '/cart/sublist',
    method: 'post',
    params: {
      uid
    },
    data: cartIds
  })
}

// 批量删除购物车商品
export function deleteCartList(uid, cartIds) {
  return request({
    url: '/cart/deletelist',
    method: 'post',
    params: {
      uid
    },
    data: cartIds
  })
}

// 更新购物车商品数量
export function updateCartNumber(id, number) {
  return request({
    url: '/cart/update',
    method: 'post',
    params: {
      id,
      quantity:number
    }
  })
}

